<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<title>StudentGrade</title>
	<link rel="stylesheet" href="css/font.css">
	<link rel="stylesheet" href="css/manageSys.css">
	<script src="js/jquery-3.1.1.min.js"></script>
</head>

<body>
<!--导航栏标题表单-->
<form id="menu_manageSys_form" action="goToModel.do" method="post">
	<!--返回管理系统首页-->
	<input type="hidden" name="modelName" value="教学管理系统"/>
	<input type="hidden" name="userName" value="${userName}"/>
</form>

<!--刷新页面表单-->
<form id="refresh_form" action="studentGradeRefresh.do" method="post"></form>

<!--导航栏-->
<div id="navbar">
	<!--导航栏标题-->
	<div id="navbar_title_div">
		<!--占位块-->
		<div style="width:100%;height:20%"></div>
		<span id="navbar_title_span">
			教学管理系统
		</span>
	</div>
	<!--导航栏标题end-->

	<!--占位块-->
	<div style="width:100%;height:5%"></div>

	<!--菜单栏-->
	<div class="menu">
		<!--重复6个菜单项-->
		<div class="menu_item_div">
			<div style="width:100%;height:10%"></div>
			<center>
				<div class="menu_item" id="setStudentInfo">
					<div style="width:100%;height:10%"></div>
					<form id="menu_setStudentInfo_form" action="goToModel.do" method="post">
						<input type="hidden" name="modelName" value="学生信息录入"/>
						<input type="hidden" name="userName" value="${userName}"/>
					</form>
					<span class="menu_item_span">学生信息录入</span>
				</div>
			</center>
		</div>
		<div class="menu_item_div">
			<div style="width:100%;height:10%"></div>
			<center>
				<div class="menu_item" id="setTeacherInfo">
					<div style="width:100%;height:10%"></div>
					<form id="menu_setTeacherInfo_form" action="goToModel.do" method="post">
						<input type="hidden" name="modelName" value="教师信息录入"/>
						<input type="hidden" name="userName" value="${userName}"/>
					</form>
					<span class="menu_item_span">教师信息录入</span>
				</div>
			</center>
		</div>
		<div class="menu_item_div">
			<div style="width:100%;height:10%"></div>
			<center>
				<div class="menu_item" id="setCourseInfo">
					<div style="width:100%;height:10%"></div>
					<form id="menu_setCourseInfo_form" action="goToModel.do" method="post">
						<input type="hidden" name="modelName" value="课程信息录入"/>
						<input type="hidden" name="userName" value="${userName}"/>
					</form>
					<span class="menu_item_span">课程信息录入</span>
				</div>
			</center>
		</div>
		<div class="menu_item_div">
			<div style="width:100%;height:10%"></div>
			<center>
				<div class="menu_item" id="studentSelection">
					<div style="width:100%;height:10%"></div>
					<form id="menu_studentSelection_form" action="goToModel.do" method="post">
						<input type="hidden" name="modelName" value="学生选课操作"/>
						<input type="hidden" name="userName" value="${userName}"/>
					</form>
					<span class="menu_item_span">学生选课操作</span>
				</div>
			</center>
		</div>
		<div class="menu_item_div">
			<div style="width:100%;height:10%"></div>
			<center>
				<div class="menu_item" id="teacherSelection">
					<div style="width:100%;height:10%"></div>
					<form id="menu_teacherSelection_form" action="goToModel.do" method="post">
						<input type="hidden" name="modelName" value="教师授课操作"/>
						<input type="hidden" name="userName" value="${userName}"/>
					</form>
					<span class="menu_item_span">教师授课操作</span>
				</div>
			</center>
		</div>
		<div class="menu_item_div">
			<div style="width:100%;height:10%"></div>
			<center>
				<div class="menu_item" id="studentGrade">
					<div style="width:100%;height:10%"></div>
					<form id="menu_studentGrade_form" action="goToModel.do" method="post">
						<input type="hidden" name="modelName" value="学生课程成绩"/>
						<input type="hidden" name="userName" value="${userName}"/>
					</form>
					<span class="menu_item_span">学生课程成绩</span>
				</div>
			</center>
		</div>
	</div>
	<!--菜单栏end-->
</div>
<!--导航栏end-->

<!--动画触发块-->
<div id="navbar_animate_div">
	<!--动画触发块标题图标-->
	<div id="navbar_animate_img_div">
		<!--占位块-->
		<div style="width:100%;height:20%"></div>
		<img class="navbar_animate_img" src="images/menu.svg"/>
	</div>
	<!--动画触发块标题图标end-->

	<!--占位块-->
	<div style="width:100%;height:5%"></div>

	<!--菜单栏图标-->
	<div class="menu">
		<!--重复6个菜单项图标-->
		<div class="menu_item_div">
			<div style="width:100%;height:10%"></div>
			<center>
				<div class="animate_menu_item">
					<div style="width:100%;height:22%"></div>
					<img class="navbar_animate_img" id="setStudentInfo_img" src="images/setStudentInfo.svg"/>
				</div>
			</center>
		</div>
		<div class="menu_item_div">
			<div style="width:100%;height:10%"></div>
			<center>
				<div class="animate_menu_item">
					<div style="width:100%;height:22%"></div>
					<img class="navbar_animate_img" id="setTeacherInfo_img" src="images/setTeacherInfo.svg"/>
				</div>
			</center>
		</div>
		<div class="menu_item_div">
			<div style="width:100%;height:10%"></div>
			<center>
				<div class="animate_menu_item">
					<div style="width:100%;height:22%"></div>
					<img class="navbar_animate_img" id="setCourseInfo_img" src="images/setCourseInfo.svg"/>
				</div>
			</center>
		</div>
		<div class="menu_item_div">
			<div style="width:100%;height:10%"></div>
			<center>
				<div class="animate_menu_item">
					<div style="width:100%;height:22%"></div>
					<img class="navbar_animate_img" id="studentSelection_img" src="images/studentSelection.svg"/>
				</div>
			</center>
		</div>
		<div class="menu_item_div">
			<div style="width:100%;height:10%"></div>
			<center>
				<div class="animate_menu_item">
					<div style="width:100%;height:22%"></div>
					<img class="navbar_animate_img" id="teacherSelection_img" src="images/teacherSelection.svg"/>
				</div>
			</center>
		</div>
		<div class="menu_item_div">
			<div style="width:100%;height:10%"></div>
			<center>
				<div class="animate_menu_item">
					<div style="width:100%;height:22%"></div>
					<img class="navbar_animate_img" id="studentGrade_img" src="images/studentGrade.svg"/>
				</div>
			</center>
		</div>
	</div>
	<!--菜单栏end-->
</div>
<!--动画触发块end-->

<!--顶部栏-->
<div id="headerbar">
	<!--占位块-->
	<div style="width:100%;height:10%"></div>

	<!--模块标题-->
	<div id="model_title">
		<!--占位块-->
		<div style="width:100%;height:6%"></div>
		<span id="model_title_span">${modelName}</span>
	</div>
	<!--模块标题end-->

	<!--数据表标题-->
	<div id="table_title">
		<!--占位块-->
		<div style="width:100%;height:6%"></div>
		<span id="table_title_span"></span>
	</div>
	<!--数据表标题end-->

	<!--用户名-->
	<div id="username">
		<!--占位块-->
		<div style="width:100%;height:6%"></div>
		<span id="welcome_span">管理员：</span>
		<span id="username_span">${userName}</span>
	</div>
	<!--用户名end-->

	<!--注销-->
	<div id="logout">
		<img id="logout_img" src="images/logout.svg"/>
		<span id="logout_span">注销</span>
	</div>
	<!--注销end-->
</div>
<!--顶部栏end-->

<!--遮罩层-->
<div id="mask_div"></div>

<!--增删改查按钮-->
<div id="idus_btn_div">
	<button class="idus_btn" id="insert_btn" type="button">增加</button>
	<script>
		/*增加按钮点击事件*/
		$("#insert_btn").click(function () {
			showInsertDoDiv();
		});
	</script>
	<button class="idus_btn" id="update_btn" type="button">修改</button>
	<script>
		/*保存旧成绩(主键)*/
		var oldStudentNum;
		var oldCourseNum;
		var oldExamTimes;
		var oldRegularGrade;
		var oldExamGrade;
		var oldTotalGrade;
		/*修改按钮点击事件*/
		$("#update_btn").click(function () {
			var radio_id = -1;//单选按钮选中位置
			/*遍历单选框获得选中id*/
			var radios = document.getElementsByName("tr_radio");
			console.log(radios);
			for (let i = 0; i < radios.length; i++) {
				if (radios[i].checked) {
					radio_id = i;
				}
			}
			if(radio_id == -1) {//没有选中radio
				alert("需要选中一条记录！");
			} else {
				oldStudentNum = $("#studentNum"+radio_id).val();
				oldCourseNum = $("#courseNum"+radio_id).val();
				oldExamTimes = $("#examTimes"+radio_id).val();
				oldRegularGrade = $("#regularGrade"+radio_id).val();
				oldExamGrade = $("#examGrade"+radio_id).val();
				oldTotalGrade = $("#totalGrade"+radio_id).val();
				/*选中记录赋值*/
				$("#updateStudentNum").val($("#studentNum"+radio_id).val());
				$("#updateCourseNum").val($("#courseNum"+radio_id).val());
				$("#updateExamTimes").val($("#examTimes"+radio_id).val());
				$("#updateRegularGrade").val($("#regularGrade"+radio_id).val());
				$("#updateExamGrade").val($("#examGrade"+radio_id).val());
				$("#updateTotalGrade").val($("#totalGrade"+radio_id).val());
				showUpdateDoDiv();
			}
		});
	</script>
	<button class="idus_btn" id="select_btn" type="button">查询</button>
	<script>
		/*查询按钮点击事件*/
		$("#select_btn").click(function () {
			showSelectDoDiv();
		});
	</script>
	<button class="idus_btn" id="delete_btn" type="button">删除</button>
	<script>
		/*删除按钮点击事件*/
		$("#delete_btn").click(function () {
			var radio_id = -1;//单选按钮选中位置
			/*遍历单选框获得选中id*/
			var radios = document.getElementsByName("tr_radio");
			console.log(radios);
			for (let i = 0; i < radios.length; i++) {
				if (radios[i].checked) {
					radio_id = i;
				}
			}
			if(radio_id == -1) {//没有选中radio
				alert("需要选中一条记录！");
			} else {
				var studentNum = $("#studentNum"+radio_id).val();
				var courseNum = $("#courseNum"+radio_id).val();
				var examTimes = $("#examTimes"+radio_id).val();
				var regularGrade = $("#regularGrade"+radio_id).val();
				var examGrade = $("#examGrade"+radio_id).val();
				var totalGrade = $("#totalGrade"+radio_id).val();
				$.ajax({//返回msg
					url:"deleteGrade.do",//请求路径
					data: {//请求数据
						"studentNum":studentNum,
						"courseNum":courseNum,
						"examTimes":examTimes,
						"regularGrade":regularGrade,
						"examGrade":examGrade,
						"totalGrade":totalGrade
					},
					type:"post",//请求类型
					success:function(data) {//返回成功处理函数
						console.log(data);
						if (data == "deleteSuccess") {
							alert("删除成功！");
							/*跳转刷新*/
							$("#refresh_form").submit();
						} else if (data == "deleteFalse") {
							alert("删除失败！");
						}
					},
					error:function() {//返回失败处理函数
						console.log(data);
						alert("ajax返回失败！");
					}
				})
			}
		});
	</script>
</div>
<!--增删改查按钮end-->

<!--增加操作框-->
<div class="ius_do_div" id="insert_do_div">
	<!--操作表，每个功能不同-->
	<div class="ius_table_div">
		<table class="ius_do_table">
			<thead>
			<tr>
				<th>学号</th>
				<th>课程号</th>
				<th>考试次数</th>
				<th>平时成绩</th>
				<th>考试成绩</th>
				<th>总评成绩</th>
			</tr>
			</thead>
			<tr class="line_tr"/>
			<tbody>
			<tr>
				<td><input class="ius_input" id="insertStudentNum"></td>
				<td><input class="ius_input" id="insertCourseNum"></td>
				<!--考试次数为数字-->
				<td><input class="ius_input" id="insertExamTimes" type="text" onkeyup="value=value.replace(/[^\d]/g,'')"></td>
				<!--平时成绩为两位小数-->
				<td><input class="ius_input" id="insertRegularGrade" type="text" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')"></td>
				<!--考试成绩为两位小数-->
				<td><input class="ius_input" id="insertExamGrade" type="text" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')"></td>
				<!--总评成绩为两位小数-->
				<td><input class="ius_input" id="insertTotalGrade" type="text" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')"></td>
			</tr>
			</tbody>
		</table>
	</div>
	<!--操作表end-->
	<!--增加、取消按钮-->
	<div class="ius_cancel_btns_div">
		<button class="ius_do_btn" id="insert_do_btn" type="button">增加</button>
		<script>
			/*子操作框增加按钮点击事件*/
			$("#insert_do_btn").click(function () {
				/*获取子操作表的值*/
				var studentNum = $("#insertStudentNum").val();
				var courseNum = $("#insertCourseNum").val();
				var examTimes = $("#insertExamTimes").val();
				var regularGrade = $("#insertRegularGrade").val();
				var examGrade = $("#insertExamGrade").val();
				var totalGrade = $("#insertTotalGrade").val();
				if (studentNum == "") {
					alert("学号不能为空！");
				} else if (courseNum == "") {
					alert("课程号不能为空！");
				} else if (examTimes != "" && (examTimes > 3 || examTimes < 1)) {
					alert("考试次数只能为1~3的整数！");
				} else if (regularGrade != "" && (regularGrade > 100 || regularGrade < 0)) {
					alert("平时成绩只能为0~100的两位小数！");
				} else if (examGrade != "" && (examGrade > 100 || examGrade < 0)) {
					alert("考试成绩只能为0~100的两位小数！");
				} else if (totalGrade != "" && (totalGrade > 100 || totalGrade < 0)) {
					alert("总评成绩只能为0~100的两位小数！");
				} else {
					$.ajax({//返回msg
						url:"insertGrade.do",//请求路径
						data: {//请求数据
							"studentNum":studentNum,
							"courseNum":courseNum,
							"examTimes":examTimes,
							"regularGrade":regularGrade,
							"examGrade":examGrade,
							"totalGrade":totalGrade
						},
						type:"post",//请求类型
						success:function(data) {//返回成功处理函数
							console.log(data);
							if (data == "gradeExist") {
								alert("成绩已存在！");
							} else if (data == "insertSuccess") {
								alert("添加成功！");
								/*跳转刷新*/
								$("#refresh_form").submit();
							} else if (data == "insertFalse") {
								alert("添加失败！");
							}
						},
						error:function() {//返回失败处理函数
							console.log(data);
							alert("ajax返回失败！");
						}
					})
				}
			});
		</script>
		<button class="ius_do_btn" id="insert_do_cancel_btn" type="button">取消</button>
	</div>
</div>
<!--增加操作框end-->

<!--修改操作框-->
<div class="ius_do_div" id="update_do_div">
	<!--操作表，每个功能不同-->
	<div class="ius_table_div">
		<table class="ius_do_table">
			<thead>
			<tr>
				<th>学号</th>
				<th>课程号</th>
				<th>考试次数</th>
				<th>平时成绩</th>
				<th>考试成绩</th>
				<th>总评成绩</th>
			</tr>
			</thead>
			<tr class="line_tr"/>
			<tbody>
			<tr>
				<td><input class="ius_input" id="updateStudentNum"></td>
				<td><input class="ius_input" id="updateCourseNum"></td>
				<!--考试次数为数字-->
				<td><input class="ius_input" id="updateExamTimes" type="text" onkeyup="value=value.replace(/[^\d]/g,'')"></td>
				<!--平时成绩为两位小数-->
				<td><input class="ius_input" id="updateRegularGrade" type="text" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')"></td>
				<!--考试成绩为两位小数-->
				<td><input class="ius_input" id="updateExamGrade" type="text" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')"></td>
				<!--总评成绩为两位小数-->
				<td><input class="ius_input" id="updateTotalGrade" type="text" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')"></td>
			</tr>
			</tbody>
		</table>
	</div>
	<!--操作表end-->
	<!--修改、取消按钮-->
	<div class="ius_cancel_btns_div">
		<button class="ius_do_btn" id="update_do_btn" type="button">修改</button>
		<script>
			/*子操作框修改按钮点击事件*/
			$("#update_do_btn").click(function () {
				/*获取子操作表的值*/
				var studentNum = $("#updateStudentNum").val();
				var courseNum = $("#updateCourseNum").val();
				var examTimes = $("#updateExamTimes").val();
				var regularGrade = $("#updateRegularGrade").val();
				var examGrade = $("#updateExamGrade").val();
				var totalGrade = $("#updateTotalGrade").val();
				if (studentNum == "") {
					alert("学号不能为空！");
				} else if (courseNum == "") {
					alert("课程号不能为空！");
				} else if (examTimes != "" && (examTimes > 3 || examTimes < 1)) {
					alert("考试次数只能为1~3的整数！");
				} else if (regularGrade != "" && (regularGrade > 100 || regularGrade < 0)) {
					alert("平时成绩只能为0~100的两位小数！");
				} else if (examGrade != "" && (examGrade > 100 || examGrade < 0)) {
					alert("考试成绩只能为0~100的两位小数！");
				} else if (totalGrade != "" && (totalGrade > 100 || totalGrade < 0)) {
					alert("总评成绩只能为0~100的两位小数！");
				} else {
					$.ajax({//返回msg
						url:"updateGrade.do",//请求路径
						data: {//请求数据
							"oldStudentNum":oldStudentNum,
							"oldCourseNum":oldCourseNum,
							"oldExamTimes":oldExamTimes,
							"oldRegularGrade":oldRegularGrade,
							"oldExamGrade":oldExamGrade,
							"oldTotalGrade":oldTotalGrade,
							"studentNum":studentNum,
							"courseNum":courseNum,
							"examTimes":examTimes,
							"regularGrade":regularGrade,
							"examGrade":examGrade,
							"totalGrade":totalGrade
						},
						type:"post",//请求类型
						success:function(data) {//返回成功处理函数
							console.log(data);
							if (data == "newGradeExist") {
								alert("新成绩已存在！");
							} else {
								if (data == "updateSuccess") {
									alert("修改成功！");
									/*跳转刷新*/
									$("#refresh_form").submit();
								} else if (data == "updateFalse") {
									alert("修改失败！");
								}
							}
						},
						error:function() {//返回失败处理函数
							console.log(data);
							alert("ajax返回失败！");
						}
					})
				}
			});
		</script>
		<button class="ius_do_btn" id="update_do_cancel_btn" type="button">取消</button>
	</div>
</div>
<!--修改操作框end-->

<!--查询操作框-->
<div class="ius_do_div" id="select_do_div">
	<!--操作表，每个功能不同-->
	<div class="ius_table_div">
		<table class="ius_do_table">
			<thead>
			<tr>
				<th>学号</th>
				<th>课程号</th>
				<th>考试次数</th>
				<th>平时成绩</th>
				<th>考试成绩</th>
				<th>总评成绩</th>
			</tr>
			</thead>
			<tr class="line_tr"/>
			<tbody>
			<tr>
				<td><input class="ius_input" name="select_input" id="selectStudentNum"></td>
				<td><input class="ius_input" name="select_input" id="selectCourseNum"></td>
				<!--考试次数为数字-->
				<td><input class="ius_input" name="select_input" id="selectExamTimes" type="text" onkeyup="value=value.replace(/[^\d]/g,'')"></td>
				<!--平时成绩为两位小数-->
				<td><input class="ius_input" name="select_input" id="selectRegularGrade" type="text" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')"></td>
				<!--考试成绩为两位小数-->
				<td><input class="ius_input" name="select_input" id="selectExamGrade" type="text" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')"></td>
				<!--总评成绩为两位小数-->
				<td><input class="ius_input" name="select_input" id="selectTotalGrade" type="text" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')"></td>
			</tr>
			</tbody>
		</table>
	</div>
	<!--操作表end-->
	<!--查询、取消按钮-->
	<div class="ius_cancel_btns_div">
		<button class="ius_do_btn" id="select_do_btn" type="button">查询</button>
		<script>
			/*子操作框查询按钮点击事件*/
			$("#select_do_btn").click(function () {
				/*获取子操作表的值*/
				var studentNum = $("#selectStudentNum").val();
				var courseNum = $("#selectCourseNum").val();
				var examTimes = $("#selectExamTimes").val();
				var regularGrade = $("#selectRegularGrade").val();
				var examGrade = $("#selectExamGrade").val();
				var totalGrade = $("#selectTotalGrade").val();

				var inputNum = 0;/*有输入的数量*/
				if (studentNum != "") inputNum++;
				if (courseNum != "") inputNum++;
				if (examTimes != "") inputNum++;
				if (regularGrade != "") inputNum++;
				if (examGrade != "") inputNum++;
				if (totalGrade != "") inputNum++;

				if (inputNum == 0) {//没有输入,查询所有记录
					alert("查询所有记录！");
					$("#table_title_span").html("所有记录");
					$("#tbody_storage").html("");//清空
					$.ajax({//返回所有记录
						url:"selectGradeAll.do",//请求路径
						data: {//请求数据
							"userName":"${userName}"
						},
						type:"post",//请求类型
						dataType:"json",//响应数据返回格式
						success:function(data) {//返回成功处理函数
							console.log(data);
							$("#tbody").html("");//清空
							$.each(data,function (index,gra){
								$("#tbody").append(
										'<tr class="line_tr"/>' +
										'<tr>'+
										'<td class="radio_td">' +
										'<input class="radio" type="radio" name="tr_radio" id="'+index+'"/>'+
										'</td>'+
										'<td>'+gra.studentNum+'</td>'+
										'<td>'+gra.courseNum+'</td>'+
										'<td>'+gra.examTimes+'</td>'+
										'<td>'+gra.regularGrade+'</td>'+
										'<td>'+gra.examGrade+'</td>'+
										'<td>'+gra.totalGrade+'</td>'+
										'</tr>'
								)
								$("#tbody_storage").append(
										'<input type="hidden" id="'+'studentNum'+index+'" value="'+gra.studentNum+'"/>'+
										'<input type="hidden" id="'+'courseNum'+index+'" value="'+gra.courseNum+'"/>'+
										'<input type="hidden" id="'+'examTimes'+index+'" value="'+gra.examTimes+'"/>'+
										'<input type="hidden" id="'+'regularGrade'+index+'" value="'+gra.regularGrade+'"/>'+
										'<input type="hidden" id="'+'examGrade'+index+'" value="'+gra.examGrade+'"/>'+
										'<input type="hidden" id="'+'totalGrade'+index+'" value="'+gra.totalGrade+'"/>'
								)
							})
						},
						error:function(data) {//返回失败处理函数
							console.log(data);
							alert("ajax返回失败！");
						}
					})
					hideSelectDoDiv();
				} else if (inputNum > 1) {//有多个输入
					alert("只能填写一项！");
				} else {//有1个输入
					if (examTimes != "" && (examTimes > 3 || examTimes < 1)) {
						alert("考试次数只能为1~3的整数！");
					} else if (regularGrade != "" && (regularGrade > 100 || regularGrade < 0)) {
						alert("平时成绩只能为0~100的两位小数！");
					} else if (examGrade != "" && (examGrade > 100 || examGrade < 0)) {
						alert("考试成绩只能为0~100的两位小数！");
					} else if (totalGrade != "" && (totalGrade > 100 || totalGrade < 0)) {
						alert("总评成绩只能为0~100的两位小数！");
					} else {
						$("#table_title_span").html("查询结果");
						$("#tbody_storage").html("");//清空
						$.ajax({//返回查询记录
							url: "selectGrade.do",//请求路径
							data: {//请求数据
								"studentNum":studentNum,
								"courseNum":courseNum,
								"examTimes":examTimes,
								"regularGrade":regularGrade,
								"examGrade":examGrade,
								"totalGrade":totalGrade
							},
							dataType: "json",//响应数据返回格式
							type: "post",//请求类型
							success: function (data) {//返回成功处理函数
								console.log(data);
								if (data.length == 0) {
									alert("查询结果为空！");
								}
								else {
									alert("查询成功！");
								}
								$("#tbody").html("");//清空
								$.each(data, function (index, gra) {
									$("#tbody").append(
											'<tr class="line_tr"/>'+
											'<tr>'+
											'<td class="radio_td">'+
											'<input class="radio" type="radio" name="tr_radio" id="'+index+'"/>'+
											'</td>'+
											'<td>'+gra.studentNum+'</td>'+
											'<td>'+gra.courseNum+'</td>'+
											'<td>'+gra.examTimes+'</td>'+
											'<td>'+gra.regularGrade+'</td>'+
											'<td>'+gra.examGrade+'</td>'+
											'<td>'+gra.totalGrade+'</td>'+
											'</tr>'
									)
									$("#tbody_storage").append(
											'<input type="hidden" id="'+'studentNum'+index+'" value="'+gra.studentNum+'"/>'+
											'<input type="hidden" id="'+'courseNum'+index+'" value="'+gra.courseNum+'"/>'+
											'<input type="hidden" id="'+'examTimes'+index+'" value="'+gra.examTimes+'"/>'+
											'<input type="hidden" id="'+'regularGrade'+index+'" value="'+gra.regularGrade+'"/>'+
											'<input type="hidden" id="'+'examGrade'+index+'" value="'+gra.examGrade+'"/>'+
											'<input type="hidden" id="'+'totalGrade'+index+'" value="'+gra.totalGrade+'"/>'
									)
								})
								hideSelectDoDiv();
								/*清空子操作表*/
								$("#selectStudentNum").val("");
								$("#selectCourseNum").val("");
								$("#selectExamTimes").val("");
								$("#selectRegularGrade").val("");
								$("#selectExamGrade").val("");
								$("#selectTotalGrade").val("");
							},
							error: function () {//返回失败处理函数
								console.log(data);
								alert("ajax返回失败！");
							}
						})
					}
				}
			});
		</script>
		<button class="ius_do_btn" id="select_do_cancel_btn" type="button">取消</button>
	</div>
</div>
<!--查询操作框end-->

<!--数据表-->
<table class="table">
	<thead>
	<tr>
		<th></th>
		<th>学号</th>
		<th>课程号</th>
		<th>考试次数</th>
		<th>平时成绩</th>
		<th>考试成绩</th>
		<th>总评成绩</th>
	</tr>
	</thead>
	<tbody id="tbody">
	</tbody>
</table>
<!--数据表end-->

<!--保存数据表数据-->
<div type="hidden" id="tbody_storage"></div>

<script>
	$(document).ready(function () {
		$("#table_title_span").html("所有记录");
		$.ajax({//返回所有记录
			url:"selectGradeAll.do",//请求路径
			data: {//请求数据
				"userName":"${userName}"
			},
			type:"post",//请求类型
			dataType:"json",//响应数据返回格式
			success:function(data) {//返回成功处理函数
				console.log(data);
				$.each(data,function (index,gra){
					$("#tbody").append(
							'<tr class="line_tr"/>'+
							'<tr>'+
							'<td class="radio_td">'+
							'<input class="radio" type="radio" name="tr_radio" id="'+index+'"/>'+
							'</td>'+
							'<td>'+gra.studentNum+'</td>'+
							'<td>'+gra.courseNum+'</td>'+
							'<td>'+gra.examTimes+'</td>'+
							'<td>'+gra.regularGrade+'</td>'+
							'<td>'+gra.examGrade+'</td>'+
							'<td>'+gra.totalGrade+'</td>'+
							'</tr>'
					)
					$("#tbody_storage").append(
							'<input type="hidden" id="'+'studentNum'+index+'" value="'+gra.studentNum+'"/>'+
							'<input type="hidden" id="'+'courseNum'+index+'" value="'+gra.courseNum+'"/>'+
							'<input type="hidden" id="'+'examTimes'+index+'" value="'+gra.examTimes+'"/>'+
							'<input type="hidden" id="'+'regularGrade'+index+'" value="'+gra.regularGrade+'"/>'+
							'<input type="hidden" id="'+'examGrade'+index+'" value="'+gra.examGrade+'"/>'+
							'<input type="hidden" id="'+'totalGrade'+index+'" value="'+gra.totalGrade+'"/>'
					)
				})
			},
			error:function(data) {//返回失败处理函数
				console.log(data);
				alert("ajax返回失败！");
			}
		})
	});

	/*导航栏动画鼠标移动事件*/
	$(document).ready(function () {//导航栏初始收回
		var animate = ${animate};
		console.log(animate);
		if (animate == 1)
		{
			$("#navbar").css('left', '50px');
			$("#navbar").stop().animate({//添加animate事件,div收回
				left: '-150px',
				height: '100%',
				width: '200px'
			});
			$("#navbar").css('left', '-150px');
		}
	});

	$("#navbar_animate_div").mouseenter(function () {//鼠标移入导航栏动画触发块
		$("#navbar").stop().animate({//添加animate事件,div弹出
			left:'50px',
			height:'100%',
			width:'200px'
		});
	});

	$("#navbar").mouseleave(function () {//鼠标移出导航栏动画触发块
		$("#navbar").stop().animate({//添加animate事件,div收回
			left:'-150px',
			height:'100%',
			width:'200px'
		});
	});

	/*注销按钮鼠标移动事件*/
	$("#logout").mouseenter(function () {//鼠标移入
		$("#logout").css('background','#999999');
	});

	$("#logout").mouseleave(function () {//鼠标移出
		$("#logout").css('background','#BDBDBD');
	});

	/*注销按钮点击事件*/
	$("#logout").click(function (){
		alert("注销成功！");
		/*$("#menu_logout_form").submit();*/
		location.href="http://localhost:8080/schoolInfoMgmtSys/";
	});

	/*菜单项鼠标移动事件*/
	$("#setStudentInfo").mouseenter(function () {//鼠标移入
		$("#setStudentInfo").css('background','rgba(240,134,80,1)');
		$("#setStudentInfo").css('box-shadow','2px 2px 1px 1px #888888');
	});

	$("#setStudentInfo").mouseleave(function () {//鼠标移出
		$("#setStudentInfo").css('background','rgba(240,134,80,0.7)');
		$("#setStudentInfo").css('box-shadow','3px 3px 4px 2px #888888');
	});

	$("#setTeacherInfo").mouseenter(function () {//鼠标移入
		$("#setTeacherInfo").css('background','rgba(240,134,80,1)');
		$("#setTeacherInfo").css('box-shadow','2px 2px 1px 1px #888888');
	});

	$("#setTeacherInfo").mouseleave(function () {//鼠标移出
		$("#setTeacherInfo").css('background','rgba(240,134,80,0.7)');
		$("#setTeacherInfo").css('box-shadow','3px 3px 4px 2px #888888');
	});

	$("#setCourseInfo").mouseenter(function () {//鼠标移入
		$("#setCourseInfo").css('background','rgba(240,134,80,1)');
		$("#setCourseInfo").css('box-shadow','2px 2px 1px 1px #888888');
	});

	$("#setCourseInfo").mouseleave(function () {//鼠标移出
		$("#setCourseInfo").css('background','rgba(240,134,80,0.7)');
		$("#setCourseInfo").css('box-shadow','3px 3px 4px 2px #888888');
	});

	$("#studentSelection").mouseenter(function () {//鼠标移入
		$("#studentSelection").css('background','rgba(240,134,80,1)');
		$("#studentSelection").css('box-shadow','2px 2px 1px 1px #888888');
	});

	$("#studentSelection").mouseleave(function () {//鼠标移出
		$("#studentSelection").css('background','rgba(240,134,80,0.7)');
		$("#studentSelection").css('box-shadow','3px 3px 4px 2px #888888');
	});

	$("#teacherSelection").mouseenter(function () {//鼠标移入
		$("#teacherSelection").css('background','rgba(240,134,80,1)');
		$("#teacherSelection").css('box-shadow','2px 2px 1px 1px #888888');
	});

	$("#teacherSelection").mouseleave(function () {//鼠标移出
		$("#teacherSelection").css('background','rgba(240,134,80,0.7)');
		$("#teacherSelection").css('box-shadow','3px 3px 4px 2px #888888');
	});

	$("#studentGrade").mouseenter(function () {//鼠标移入
		$("#studentGrade").css('background','rgba(240,134,80,1)');
		$("#studentGrade").css('box-shadow','2px 2px 1px 1px #888888');
	});

	$("#studentGrade").mouseleave(function () {//鼠标移出
		$("#studentGrade").css('background','rgba(240,134,80,0.7)');
		$("#studentGrade").css('box-shadow','3px 3px 4px 2px #888888');
	});

	/*导航栏标题点击事件*/
	$("#navbar_title_div").click(function (){
		$("#menu_manageSys_form").submit();
	});

	/*菜单项按钮点击事件*/
	$("#setStudentInfo").click(function (){
		$("#menu_setStudentInfo_form").submit();
	});

	$("#setTeacherInfo").click(function (){
		$("#menu_setTeacherInfo_form").submit();
	});

	$("#setCourseInfo").click(function (){
		$("#menu_setCourseInfo_form").submit();
	});

	$("#studentSelection").click(function (){
		$("#menu_studentSelection_form").submit();
	});

	$("#teacherSelection").click(function (){
		$("#menu_teacherSelection_form").submit();
	});

	$("#studentGrade").click(function (){
		$("#menu_studentGrade_form").submit();
	});

	/*菜单项图标点击事件*/
	$("#setStudentInfo_img").click(function (){
		$("#menu_setStudentInfo_form").submit();
	});

	$("#setTeacherInfo_img").click(function (){
		$("#menu_setTeacherInfo_form").submit();
	});

	$("#setCourseInfo_img").click(function (){
		$("#menu_setCourseInfo_form").submit();
	});

	$("#studentSelection_img").click(function (){
		$("#menu_studentSelection_form").submit();
	});

	$("#teacherSelection_img").click(function (){
		$("#menu_teacherSelection_form").submit();
	});

	$("#studentGrade_img").click(function (){
		$("#menu_studentGrade_form").submit();
	});

	/*增删改查按钮鼠标移动事件*/
	$("#insert_btn").mouseenter(function () {//鼠标移入
		$("#insert_btn").css('background','#2281B0');
		$("#insert_btn").css('box-shadow','2px 2px 1px 1px #888888');
	});

	$("#insert_btn").mouseleave(function () {//鼠标移出
		$("#insert_btn").css('background','#30B4F6');
		$("#insert_btn").css('box-shadow','3px 3px 2px 2px #888888');
	});

	$("#update_btn").mouseenter(function () {//鼠标移入
		$("#update_btn").css('background','#2281B0');
		$("#update_btn").css('box-shadow','2px 2px 1px 1px #888888');
	});

	$("#update_btn").mouseleave(function () {//鼠标移出
		$("#update_btn").css('background','#30B4F6');
		$("#update_btn").css('box-shadow','3px 3px 2px 2px #888888');
	});

	$("#select_btn").mouseenter(function () {//鼠标移入
		$("#select_btn").css('background','#2281B0');
		$("#select_btn").css('box-shadow','2px 2px 1px 1px #888888');
	});

	$("#select_btn").mouseleave(function () {//鼠标移出
		$("#select_btn").css('background','#30B4F6');
		$("#select_btn").css('box-shadow','3px 3px 2px 2px #888888');
	});

	$("#delete_btn").mouseenter(function () {//鼠标移入
		$("#delete_btn").css('background','#2281B0');
		$("#delete_btn").css('box-shadow','2px 2px 1px 1px #888888');
	});

	$("#delete_btn").mouseleave(function () {//鼠标移出
		$("#delete_btn").css('background','#30B4F6');
		$("#delete_btn").css('box-shadow','3px 3px 2px 2px #888888');
	});

	/*增加子输入框展示/隐藏函数*/
	function showInsertDoDiv() {
		$("#mask_div").css('display','inherit');
		$("#insert_do_div").css('display','inherit');
	}

	function hideInsertDoDiv() {
		$("#mask_div").css('display','none');
		$("#insert_do_div").css('display','none');
	}

	/*修改子输入框展示/隐藏函数*/
	function showUpdateDoDiv() {
		$("#mask_div").css('display','inherit');
		$("#update_do_div").css('display','inherit');
	}

	function hideUpdateDoDiv() {
		$("#mask_div").css('display','none');
		$("#update_do_div").css('display','none');
	}

	/*查询子输入框展示/隐藏函数*/
	function showSelectDoDiv() {
		$("#mask_div").css('display','inherit');
		$("#select_do_div").css('display','inherit');
	}

	function hideSelectDoDiv() {
		$("#mask_div").css('display','none');
		$("#select_do_div").css('display','none');
		$("#select_do_div").css('display','none');
	}

	/*增加、修改、查询和取消按钮鼠标移动事件*/
	$("#insert_do_btn").mouseenter(function () {//鼠标移入
		$("#insert_do_btn").css('background','#CFCFCF');
	});

	$("#insert_do_btn").mouseleave(function () {//鼠标移出
		$("#insert_do_btn").css('background','#F2F2F2');
	});

	$("#insert_do_cancel_btn").mouseenter(function () {//鼠标移入
		$("#insert_do_cancel_btn").css('background','#CFCFCF');
	});

	$("#insert_do_cancel_btn").mouseleave(function () {//鼠标移出
		$("#insert_do_cancel_btn").css('background','#F2F2F2');
	});

	$("#update_do_btn").mouseenter(function () {//鼠标移入
		$("#update_do_btn").css('background','#CFCFCF');
	});

	$("#update_do_btn").mouseleave(function () {//鼠标移出
		$("#update_do_btn").css('background','#F2F2F2');
	});

	$("#update_do_cancel_btn").mouseenter(function () {//鼠标移入
		$("#update_do_cancel_btn").css('background','#CFCFCF');
	});

	$("#update_do_cancel_btn").mouseleave(function () {//鼠标移出
		$("#update_do_cancel_btn").css('background','#F2F2F2');
	});

	$("#select_do_btn").mouseenter(function () {//鼠标移入
		$("#select_do_btn").css('background','#CFCFCF');
	});

	$("#select_do_btn").mouseleave(function () {//鼠标移出
		$("#select_do_btn").css('background','#F2F2F2');
	});

	$("#select_do_cancel_btn").mouseenter(function () {//鼠标移入
		$("#select_do_cancel_btn").css('background','#CFCFCF');
	});

	$("#select_do_cancel_btn").mouseleave(function () {//鼠标移出
		$("#select_do_cancel_btn").css('background','#F2F2F2');
	});

	/*子操作框取消按钮点击事件*/
	$("#insert_do_cancel_btn").click(function () {
		hideInsertDoDiv();
	});

	$("#update_do_cancel_btn").click(function () {
		hideUpdateDoDiv();
	});

	$("#select_do_cancel_btn").click(function () {
		hideSelectDoDiv();
	});
</script>
</body>
</html>